package com.edou.member.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.member.dao.IMemberUserCompanyDao;
import com.edou.member.entity.MemberUserCompany;
import com.edou.member.service.IMemberUserCompanyService;

import com.edou.member.dto.MemberUserCompanyCondition;

/**
 * 会员企业关联表
 * @creator     
 * @create-time 2016/4/25 15:00:52
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
@Service("memberUserCompanyServiceImpl")
@Transactional(value = "transactionManager")
public class MemberUserCompanyServiceImpl implements IMemberUserCompanyService{

	@Resource(name = "memberUserCompanyDaoImpl")
	private IMemberUserCompanyDao memberUserCompanyDao;

	/**
	 * 查询所有会员企业关联表
	 */
	public List<MemberUserCompany> listMemberUserCompanyAll(){
		return memberUserCompanyDao.listMemberUserCompanyAll();
	}

	/**
	 * 分页查询
	 * @param pageResult 分页对象
	 * @param condition 查询条件类
	 */
	public void listMemberUserCompanyByPage(PageResult<MemberUserCompany> pageResult,MemberUserCompanyCondition condition){
		int rows = memberUserCompanyDao.listMemberUserCompanyByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<MemberUserCompany> list = memberUserCompanyDao.listMemberUserCompanyByPage(rowBounds,condition);
		pageResult.setResult(list);
	}

	/**
	 * 根据ID查询
	 * @param id 主键
	 * @return 会员企业关联表
	 */
	public MemberUserCompany getMemberUserCompanyById(String id){
		return memberUserCompanyDao.getMemberUserCompanyById(id);
	}

	/**
	 * 新增
	 * @param item 会员企业关联表
	 */
	public void add(MemberUserCompany item){
		memberUserCompanyDao.add(item);
	}

	/**
	 * 修改
	 * @param item 会员企业关联表
	 */
	public void update(MemberUserCompany item){
		memberUserCompanyDao.update(item);
	}

	/**
	 * 根据ID集合批量删除
	 * @param ids ID集合
	 */
	public void delByIds(String[] ids){
		memberUserCompanyDao.delByIds(ids);
	}

	/**
	 * 根据会员id和是否子节点，查找集团和医院 
	 */
	public MemberUserCompany getMemberUserCompanyByUserIdAndIsleaf(String memberUserId, Integer isLeaf) {
		return memberUserCompanyDao.getMemberUserCompanyByUserIdAndIsleaf(memberUserId, isLeaf);
	}

	/**
	 * 根据memberUserId查询
	 */
	public MemberUserCompany getMemberUserCompanyByUserId(String memberUserId) {
		return memberUserCompanyDao.getMemberUserCompanyByUserId(memberUserId);
	}

}

